/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author The Lunatics
 */
@Entity
@Table(name = "managers")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Managers.findAll", query = "SELECT m FROM Managers m"),
    @NamedQuery(name = "Managers.findByStartDate", query = "SELECT m FROM Managers m WHERE m.startDate = :startDate"),
    @NamedQuery(name = "Managers.findByHourlyRate", query = "SELECT m FROM Managers m WHERE m.hourlyRate = :hourlyRate"),
    @NamedQuery(name = "Managers.findByManagerId", query = "SELECT m FROM Managers m WHERE m.managerId = :managerId")})
public class Managers implements Serializable {
    private static final long serialVersionUID = 1L;
    @Size(max = 20)
    @Column(name = "Start_Date")
    private String startDate;
    @Column(name = "Hourly_Rate")
    private Integer hourlyRate;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "Manager_Id")
    private Integer managerId;
    @JoinColumn(name = "SSN", referencedColumnName = "SSN")
    @ManyToOne
    private Persons ssn;
    @OneToMany(mappedBy = "manager")
    private Collection<Employees> employeesCollection;

    public Managers() {
    }

    public Managers(Integer managerId) {
        this.managerId = managerId;
    }

    public String getStartDate() {
        return startDate;
    }

    public void setStartDate(String startDate) {
        this.startDate = startDate;
    }

    public Integer getHourlyRate() {
        return hourlyRate;
    }

    public void setHourlyRate(Integer hourlyRate) {
        this.hourlyRate = hourlyRate;
    }

    public Integer getManagerId() {
        return managerId;
    }

    public void setManagerId(Integer managerId) {
        this.managerId = managerId;
    }

    public Persons getSsn() {
        return ssn;
    }

    public void setSsn(Persons ssn) {
        this.ssn = ssn;
    }

    @XmlTransient
    public Collection<Employees> getEmployeesCollection() {
        return employeesCollection;
    }

    public void setEmployeesCollection(Collection<Employees> employeesCollection) {
        this.employeesCollection = employeesCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (managerId != null ? managerId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Managers)) {
            return false;
        }
        Managers other = (Managers) object;
        if ((this.managerId == null && other.managerId != null) || (this.managerId != null && !this.managerId.equals(other.managerId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Managers[ managerId=" + managerId + " ]";
    }
    
}
